#! /bin/bash

mkdir -p /opt/startup/frpc/

cd /tmp/
wget http://sunovo-sunovo.stor.sinaapp.com/frp/frp_0.35.1_linux_amd64.tar.gz
cp frp_0.35.1_linux_amd64.tar.gz /opt/startup/frpc/
cd /opt/startup/frpc/
tar -xvzf frp_0.35.1_linux_amd64.tar.gz

cd frp_0.35.1_linux_amd64/
rm frpc.ini
wget http://sunovo-sunovo.stor.sinaapp.com/frp/frpc.ini

echo "[Install]" >> /lib/systemd/system/rc.local.service
echo "WantedBy=multi-user.target" >> /lib/systemd/system/rc.local.service
echo "Alias=rc-local.service" >> /lib/systemd/system/rc.local.service

systemctl enable rc.local.service

touch /etc/rc.local
chmod 755 /etc/rc.local

echo "#! /bin/bash" >> /etc/rc.local
echo "cd /opt/startup/frpc/" >> /etc/rc.local
echo "nohup ./frpc -c frpc.ini >> /var/log/frpc.log 2>&1 &" >> /etc/rc.local

reboot